import 'package:pull_to_refresh/pull_to_refresh.dart';

import '../../public.dart';

class Finder extends StatefulWidget {
  @override
  _Finder createState() => _Finder();
}

class _Finder extends State<Finder> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  RefreshController _refreshController =
      RefreshController(initialRefresh: false);
//  HideAlways
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
//    super.build(context);
    return ProviderWidget<FinderModel>(
        model: FinderModel(Provider.of<ThemeModel>(context)),
        onModelReady: (model) async => model.initData(),
        builder: (context, model, child) {
          if (model.busy) {
            return ViewStateBusyWidget();
          } else if (model.error) {
            return ViewStateWidget(onPressed: model.initData);
          } else if (model.empty) {
            return ViewStateEmptyWidget(onPressed: model.initData);
          }
          return Container(
            child: SmartRefresher(
              enablePullDown: false,
              enablePullUp: false,
              controller: _refreshController,
              physics: BouncingScrollPhysics(),
              child: Container(
                color: model.themeModel.currentBrightness == Brightness.dark
                    ? Colors.black
                    : Colors.white,
                child: Container(
                  margin:
                      EdgeInsets.fromLTRB(0, ScreenUtil().setHeight(20), 0, 0),
                  color: Color(0xFFF2F2F2),
                  child: Column(
                    children: <Widget>[
                      Container(
                        child: Material(
                          child: Ink(
                            color: Color(0xFFFFFFFF),
                            child: InkWell(
                              onTap: () {
                                AppConfig.router.navigateTo(
                                    context, '/search_book',
                                    transition: TransitionType.inFromRight);
                              },
                              child: Container(
                                alignment: Alignment.centerLeft,
                                height: ScreenUtil().setHeight(100),
                                width: ScreenUtil().setWidth(1334),
                                child: Row(
                                  children: <Widget>[
                                    Expanded(
                                      flex: 2,
                                      child: Container(
                                        child: Icon(
                                            IconData(
                                              0xe674,
                                              fontFamily: 'iconfont_icon',
                                            ),
                                            size: ScreenUtil().setSp(45),
                                            color: Color(0xFF673ab7)),
                                      ),
                                    ),
                                    Expanded(
                                      flex: 9,
                                      child: Text(
                                        "搜索",
                                        style: TextStyle(
                                            fontSize: ScreenUtil().setSp(30)),
                                      ),
                                    ),
                                    Expanded(
                                      flex: 1,
                                      child: Container(),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
          );
        });
  }
//
//  @override
//  // TODO: implement wantKeepAlive
//  bool get wantKeepAlive => true;
}
